<template>
  <el-container class="personalcenter">
    <el-header style="height: 40px">
      <span>个人中心</span>
    </el-header>

    <el-container>
      <el-aside width="200px">
        <el-menu :default-active="menuActive" @select="selectMenu">
          <el-menu-item
            v-for="item in menuList"
            :key="item.key"
            :index="item.key"
          >{{ item.title }}</el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <UserInfo v-if="menuActive === menuKeys.info" />
        <ModPwd v-if="menuActive === menuKeys.modPws" />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { mapGetters } from 'vuex'
import UserInfo from './component/UserInfo'
import ModPwd from './component/ModPwd'

export default {
  name: 'Dashboard',
  components: {
    UserInfo,
    ModPwd
  },
  data() {
    const menuKeys = {
      info: '1',
      modPws: '2'
    }
    return {
      menuKeys,
      menuList: [
        { key: menuKeys.info, title: '个人信息' },
        { key: menuKeys.modPws, title: '修改密码' }
      ],
      menuActive: menuKeys.info
    }
  },
  computed: {
    ...mapGetters(['userName'])
  },
  methods: {
    selectMenu(key) {
      this.menuActive = key
    }
  }
}
</script>

<style lang="scss" scoped>
$bg-color: #9580f9;

.personalcenter {
  margin: 20px 100px;
      border: 1px solid #e6e9ec;
    box-shadow: 0px 1px 9px #e6e9ec;
}

.el-header {
  color: #fff;
  line-height: 40px;
  height: 40px;
  text-align: center;
  color: #000;
      font-size: 24px;
    border: 1px solid #e6e9ec;
    box-shadow: 0px 1px 9px #e6e9ec;
}

.el-aside {
  height: calc(100vh - 200px);
  background-color: #fcfcfc;
  border: 1px solid #e6e9ec;
  box-shadow: 0px 1px 9px #e6e9ec;
  >>>.el-menu{
    margin-top: 10px;
  }
>>>.el-menu-item.is-active{
      background: #ebeffe;
}
}
</style>
